/* tslint:disable */
/* eslint-disable */
/*
Humanloop API

The Humanloop API allows you to interact with Humanloop from your product or service.

You can do this through HTTP requests from any language or via our official Python or TypeScript SDK.

To install the official [Python SDK](https://pypi.org/project/humanloop/), run the following command:

```bash
pip install humanloop
```

To install the official [TypeScript SDK](https://www.npmjs.com/package/humanloop), run the following command:

```bash
npm i humanloop
```

---

Guides and further details about key concepts can be found in [our docs](https://docs.humanloop.com/).

The version of the OpenAPI document: 4.0.1


NOTE: This file is auto generated by Konfig (https://konfigthis.com).
*/

import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import { Configuration } from '../configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, isBrowser } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
// @ts-ignore
import { CreateSessionResponse } from '../models';
// @ts-ignore
import { HTTPValidationError } from '../models';
// @ts-ignore
import { PaginatedDataSessionResponse } from '../models';
// @ts-ignore
import { SessionResponse } from '../models';
import { paginate } from "../pagination/paginate";
import type * as buffer from "buffer"
import { requestBeforeHook } from '../requestBeforeHook';
/**
 * SessionsApi - axios parameter creator
 * @export
 */
export const SessionsApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Create a new session.  Returns a session ID that can be used to log datapoints to the session.
         * @summary Create
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        create: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/sessions`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions: AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = configuration && !isBrowser() ? { "User-Agent": configuration.userAgent } : {} as any;
            const localVarQueryParameter = {} as any;

            // authentication APIKeyHeader required
            await setApiKeyToObject({ object: localVarHeaderParameter, key: "X-API-KEY", keyParamName: "xAPIKEY", configuration })

    
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            requestBeforeHook({
                queryParameters: localVarQueryParameter,
                requestConfig: localVarRequestOptions,
                path: localVarPath,
                configuration,
                pathTemplate: '/sessions',
                httpMethod: 'POST'
            });

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Get a session by ID.
         * @summary Get
         * @param {string} id String ID of session to return. Starts with &#x60;sesh_&#x60;.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        get: async (id: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('get', 'id', id)
            const localVarPath = `/sessions/{id}`
                .replace(`{${"id"}}`, encodeURIComponent(String(id !== undefined ? id : `-id-`)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions: AxiosRequestConfig = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = configuration && !isBrowser() ? { "User-Agent": configuration.userAgent } : {} as any;
            const localVarQueryParameter = {} as any;

            // authentication APIKeyHeader required
            await setApiKeyToObject({ object: localVarHeaderParameter, key: "X-API-KEY", keyParamName: "xAPIKEY", configuration })

    
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            requestBeforeHook({
                queryParameters: localVarQueryParameter,
                requestConfig: localVarRequestOptions,
                path: localVarPath,
                configuration,
                pathTemplate: '/sessions/{id}',
                httpMethod: 'GET'
            });

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Get a page of sessions.
         * @summary List 
         * @param {string} projectId String ID of project to return sessions for. Sessions that contain any datapoints associated to this project will be returned. Starts with &#x60;pr_&#x60;.
         * @param {number} [page] Page to fetch. Starts from 1.
         * @param {number} [size] Number of sessions to retrieve.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        list: async (projectId: string, page?: number, size?: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'projectId' is not null or undefined
            assertParamExists('list', 'projectId', projectId)
            const localVarPath = `/sessions`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions: AxiosRequestConfig = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = configuration && !isBrowser() ? { "User-Agent": configuration.userAgent } : {} as any;
            const localVarQueryParameter = {} as any;

            // authentication APIKeyHeader required
            await setApiKeyToObject({ object: localVarHeaderParameter, key: "X-API-KEY", keyParamName: "xAPIKEY", configuration })
            if (projectId !== undefined) {
                localVarQueryParameter['project_id'] = projectId;
            }

            if (page !== undefined) {
                localVarQueryParameter['page'] = page;
            }

            if (size !== undefined) {
                localVarQueryParameter['size'] = size;
            }


    
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            requestBeforeHook({
                queryParameters: localVarQueryParameter,
                requestConfig: localVarRequestOptions,
                path: localVarPath,
                configuration,
                pathTemplate: '/sessions',
                httpMethod: 'GET'
            });

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    }
};

/**
 * SessionsApi - functional programming interface
 * @export
 */
export const SessionsApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = SessionsApiAxiosParamCreator(configuration)
    return {
        /**
         * Create a new session.  Returns a session ID that can be used to log datapoints to the session.
         * @summary Create
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async create(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CreateSessionResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.create(options);
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
        },
        /**
         * Get a session by ID.
         * @summary Get
         * @param {SessionsApiGetRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async get(requestParameters: SessionsApiGetRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SessionResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.get(requestParameters.id, options);
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
        },
        /**
         * Get a page of sessions.
         * @summary List 
         * @param {SessionsApiListRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async list(requestParameters: SessionsApiListRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedDataSessionResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.list(requestParameters.projectId, requestParameters.page, requestParameters.size, options);
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
        },
    }
};

/**
 * SessionsApi - factory interface
 * @export
 */
export const SessionsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = SessionsApiFp(configuration)
    return {
        /**
         * Create a new session.  Returns a session ID that can be used to log datapoints to the session.
         * @summary Create
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        create(options?: AxiosRequestConfig): AxiosPromise<CreateSessionResponse> {
            return localVarFp.create(options).then((request) => request(axios, basePath));
        },
        /**
         * Get a session by ID.
         * @summary Get
         * @param {SessionsApiGetRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        get(requestParameters: SessionsApiGetRequest, options?: AxiosRequestConfig): AxiosPromise<SessionResponse> {
            return localVarFp.get(requestParameters, options).then((request) => request(axios, basePath));
        },
        /**
         * Get a page of sessions.
         * @summary List 
         * @param {SessionsApiListRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        list(requestParameters: SessionsApiListRequest, options?: AxiosRequestConfig): AxiosPromise<PaginatedDataSessionResponse> {
            return localVarFp.list(requestParameters, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * Request parameters for get operation in SessionsApi.
 * @export
 * @interface SessionsApiGetRequest
 */
export type SessionsApiGetRequest = {
    
    /**
    * String ID of session to return. Starts with `sesh_`.
    * @type {string}
    * @memberof SessionsApiGet
    */
    readonly id: string
    
}

/**
 * Request parameters for list operation in SessionsApi.
 * @export
 * @interface SessionsApiListRequest
 */
export type SessionsApiListRequest = {
    
    /**
    * String ID of project to return sessions for. Sessions that contain any datapoints associated to this project will be returned. Starts with `pr_`.
    * @type {string}
    * @memberof SessionsApiList
    */
    readonly projectId: string
    
    /**
    * Page to fetch. Starts from 1.
    * @type {number}
    * @memberof SessionsApiList
    */
    readonly page?: number
    
    /**
    * Number of sessions to retrieve.
    * @type {number}
    * @memberof SessionsApiList
    */
    readonly size?: number
    
}

/**
 * SessionsApiGenerated - object-oriented interface
 * @export
 * @class SessionsApiGenerated
 * @extends {BaseAPI}
 */
export class SessionsApiGenerated extends BaseAPI {
    /**
     * Create a new session.  Returns a session ID that can be used to log datapoints to the session.
     * @summary Create
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof SessionsApiGenerated
     */
    public create(options?: AxiosRequestConfig) {
        return SessionsApiFp(this.configuration).create(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Get a session by ID.
     * @summary Get
     * @param {SessionsApiGetRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof SessionsApiGenerated
     */
    public get(requestParameters: SessionsApiGetRequest, options?: AxiosRequestConfig) {
        return SessionsApiFp(this.configuration).get(requestParameters, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Get a page of sessions.
     * @summary List 
     * @param {SessionsApiListRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof SessionsApiGenerated
     */
    public list(requestParameters: SessionsApiListRequest, options?: AxiosRequestConfig) {
        return paginate({
            initialParameters: requestParameters,
            request: (parameters: SessionsApiListRequest) => {
                return SessionsApiFp(this.configuration).list(parameters, options).then((request) => request(this.axios, this.basePath));
            },
        });
    }
}
